<?php

require_once  __DIR__ . '/includes/authenticate.php';

include_once './db_bb_connect.php';

$sql = "SELECT DISTINCT season 
		FROM teams
		ORDER BY season";

$result = $db->query($sql);

?>

<br/>


<div id="row">
<div id="col-md-12">

<form method="post" action="" class="hidden-print"> 
  <center><h3>View Profile</h3></center>
	<div class="form-group">
	  <div class="col-md-offset-3 col-md-6">        
	<select name="season" class="form-control">
	    <option id="selected-season" value="" disabled="disabled" selected="selected">Select a season</option>";

<?php
while ($row = $result->fetch_assoc()) {
				$season = $row['season'];
				echo "<option value=\"$season\">$season</option>";
};
?>

	</select>
	</div>
	</div>

</form>
</div>
</div>


<br>
<div id="row">
<div id="col-md-12">
<div id="selectplayer"></div>
</div>


<br>

<script type="text/javascript">
	
$("select").on( "change", function( e ) {
  postData = $(this).serialize();
  $.ajax({
  	type: "POST",
  	url: "./playerprofile_selectplayer.php",
  	data: postData,
  	success: function(data) {
  		$("#selectplayer").html(data);
  	},
  	error: function(xhr, status, error){
  		$("#selectplayer").html(xhr.responseText);
  	}
  }); 
  e.preventDefault();
});


</script>

